package com.quanyan.ic.vendingMachine.mapper.customSQL;

import org.apache.ibatis.jdbc.SQL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Administrator on 2017/8/23.
 */
public class VmUpgradeMapperSqlProvider {

    private Logger logger = LoggerFactory.getLogger(VmUpgradeMapperSqlProvider.class);
    public String findFileNameCurrent(final String fileName) {
        SQL sql = new SQL(){
            {
                SELECT("v.file_type AS fileType,v.is_upgrade AS isUpgrade,v.download_url AS downloadUrl, " +
                        " v.version_code AS versionCode,v.name AS name");
                FROM("vm_upgrade v");
                WHERE("file_type='" + fileName + "'");
                AND();
                WHERE("version_code=(select MAX(version_code) from vm_upgrade )" );
            }
        } ;
        logger.info("findFileNameCurrent SQL: \n{}", sql.toString());
        return sql.toString();
    }
}
